package Exercise1;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class CreateFileTest {
    public static void main(String args[]) throws IOException {
        File file = new File("d:\\mytemp");
        if(!file.exists())
        {
            file.mkdir();
        }
        File file1 = new File("d:\\mytemp\\hello.txt");
        if(file1.exists())
        {
            System.out.println("已存在，不再需要创建");
            FileWriter fw = new FileWriter(file1);
            fw.write("hello world");
            fw.close();
        }
        else
        {
            file1.createNewFile();
            System.out.println("创建成功");
        }
    }
}
